' ***^^^***|||***^^^***
' 
'  This file is regenerated until it's edited. Delete the file to force regeneration.

'  NOTE: This denotes the way the file was created and it's possible the 
'        generation type has since changed.
'        Check the generation script for the curent state of the file.

' %%%###%%%1b0e987669ef9f96570fdfe713a23810%%%###%%%
' %%%##NoWS##%%%19d0a1422612660a7f62a88be657b715%%%##NoWS##%%%
' ***^^^***|||***^^^***


'************************************************************************************
' Copyright © 2003-2006 Kathleen Dollard
'
' This software is provided 'as-is', without any express or implied warranty. In no 
' event will the author be held liable for any damages arising from the use of this
' software.
' 
' You may use this software for any purpose, including commercial applications, 
' and you may redistribute this software as part of application delivery: however, 
' this copyright notice may not be removed and you may not otherwise redistribute 
' this software directly other than providing a link to wwww.gendotnet.com. 
'
' You may alter this software to better server your needs (I'd like to hear about your 
' changes in order to make the software better). If you alter the softwre, you must  
' clearly mark it as altered and must not be misrepresented as the original software.
' nor wholly your original work.
'*************************************************************************************

Option Explicit On
Option Strict On

Imports System
Imports System.Collections.Generic



Public Class DbsTable
   Implements IViewOrTable

   Private ReadOnly Property DbsDataStructures1() As DbsDataStructureCollection Implements IViewOrTable.DbsDataStructures
      Get
         Return MyBase.DbsDataStructures
      End Get
   End Property

#Region "IViewOrTable Implementation"

   Private Property Name1() As String Implements IViewOrTable.Name
      Get
         Return MyBase.Name
      End Get
      Set(ByVal value As String)
         MyBase.Name = value
      End Set
   End Property

   Private Property PluralName1() As String Implements IViewOrTable.PluralName
      Get
         Return MyBase.PluralName
      End Get
      Set(ByVal value As String)
         MyBase.PluralName = value
      End Set
   End Property

   Private Property Schema1() As String Implements IViewOrTable.Schema
      Get
         Return MyBase.Schema
      End Get
      Set(ByVal value As String)
         MyBase.Schema = value
      End Set
   End Property

   Private Property SingularName1() As String Implements IViewOrTable.SingularName
      Get
         Return MyBase.SingularName
      End Get
      Set(ByVal value As String)
         MyBase.SingularName = value
      End Set
   End Property

   Private Property OriginalName1() As String Implements IViewOrTable.OriginalName
      Get
         Return MyBase.OriginalName
      End Get
      Set(ByVal value As String)
         MyBase.OriginalName = value
      End Set
   End Property


   Private ReadOnly Property ViewOrTableColumns() _
            As IViewOrTableColumnCollection _
            Implements IViewOrTable.ViewOrTableColumns
      Get
         Return MyBase.DbsTableColumns
      End Get
   End Property

   Private ReadOnly Property DbsPrimaryKeys1() As DbsPrimaryKeyCollection Implements IViewOrTable.DBSPrimaryKeys
      Get
         Return MyBase.DbsPrimaryKeys
      End Get
   End Property

   Public ReadOnly Property IsTable() As Boolean Implements IViewOrTable.IsTable
      Get
         Return True
      End Get
   End Property

   Private ReadOnly Property Attributes1() As Attributes Implements IViewOrTable.Attributes
      Get
         Return MyBase.Attributes
      End Get
   End Property
#End Region
End Class

Public Class DbsTableCollection
   Default Public Overloads ReadOnly Property Item(ByVal name As String) As DbsTable
      Get
         For Each table As DbsTable In Me
            If table.Name = name OrElse table.OriginalName = name Then
               Return table
            End If
         Next
         Return Nothing
      End Get
   End Property

   Public Function GetTable(ByVal name As String) As DbsTable
      Return GetTable(name, False, False)
   End Function

   Public Function GetTable(ByVal name As String, ByVal useSingular As Boolean, ByVal usePlural As Boolean) As DbsTable
      Dim ret As DbsTable = Me(name)
      If ret Is Nothing And usePlural Then
         Dim singular As String = Utility2005.Tools.GetSingular(name)
         ret = Me(singular)
      End If

      If ret Is Nothing And useSingular Then
         Dim plural As String = Utility2005.Tools.GetPlural(name)
         ret = Me(plural)
      End If
      Return ret
   End Function

   Public Function GetTableBySingularName(ByVal name As String) As DbsTable
      For Each table As DbsTable In Me
         If table.SingularName = name Then
            Return table
         End If
      Next
      Return Nothing
   End Function

End Class

